package com.bw.umeng_sdk;

import android.content.Context;

import com.meituan.android.walle.WalleChannelReader;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;

import java.util.Map;

public class UMengManager {
    private UMengManager() {
    }

    private static UMengManager instance;
    private Context context;

    public static UMengManager getInstance() {
        if (instance == null) {
            instance = new UMengManager();
        }
        return instance;
    }

    //UMeng初始化
    public void initUMeng(Context context) {
        this.context = context;
        //读取瓦力打包出来得渠道包得渠道号
        String channel = "";
        channel = WalleChannelReader.getChannel(context);
        if (channel == null)
            channel = "test";
        //初始化umeng
        UMConfigure.setLogEnabled(true);
        UMConfigure.init(context, UmengConst.UMENGKEY, channel,
                UMConfigure.DEVICE_TYPE_PHONE, UmengConst.UMENGSECRET);
        //配置微博开放平台申请接入信息
        PlatformConfig.setSinaWeibo(UmengConst.SINAKEY, UmengConst.SINASECRET,
                UmengConst.SINABACKURL);
        PlatformConfig.setSinaFileProvider("com.bw.umeng_sdk.fileprovider");
        //手动集成
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
    }

    //统计感兴趣的视频
    public void totalLikedTag(Map<String,Object> map,String event){
        MobclickAgent.onEventObject(context,event,map);
    }
}
